package com.yunchang.springboot.mapper.mwsfinance;

import com.yunchang.springboot.models.mwsfinance.FInventoryDaily;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@Mapper
public interface FInventoryDailyMapper {

    /**
     * 根据id删除FInventoryDaily对象
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Long id);

    /**
     * 根据FInventoryDaily增加一条数据
     * @param record
     * @return
     */
    int insert(FInventoryDaily record);

    /**
     * 根据FInventoryDaily对象有选择的增加一条数据
     * @param record
     * @return
     */
    int insertSelective(FInventoryDaily record);

    /**
     * 根据id获取FInventoryDaily对象
     * @param id
     * @return
     */
    FInventoryDaily selectByPrimaryKey(Long id);

    /**
     * 根据id和FInventoryDaily对象有选择的更新
     * @param record
     * @return
     */
    int updateByPrimaryKeySelective(FInventoryDaily record);

    /**
     * 根据id和FInventoryDaily对象更新
     * @param record
     * @return
     */
    int updateByPrimaryKey(FInventoryDaily record);

    /**
     * 根据下面的参数获取FInventoryDaily对象
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouse
     * @param relatedId
     * @param stockSku
     * @param date
     * @return
     */
    FInventoryDaily selectBySellerIdAndCountryAndSkuAndWarehouseAndRelatedIdAndDateAndStockSku(String sellerId,String country,String sku,String warehouse,String relatedId,String stockSku,String date);

    /**
     * 根据下面的参数获取FInventoryDaily对象
     * @param sellerId
     * @param country
     * @param warehouse
     * @param relatedId
     * @param stockSku
     * @param date
     * @return
     */
    FInventoryDaily selectBySellerIdAndCountryAndWarehouseAndRelatedIdAndDateAndStockSku(String sellerId,String country,String warehouse,String relatedId,String stockSku,String date);

    /**
     *根据参数获取库存
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouse
     * @param relatedId
     * @param date
     * @return
     */
    FInventoryDaily selectBySellerIdAndCountryAndSkuAndWarehouseAndRelatedIdAndDate(String sellerId,String country,String sku,String warehouse,String relatedId,String date);

    /**
     * 获取
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouse
     * @param date
     * @return
     */
    FInventoryDaily selectBySellerIdAndCountryAndSkuAndWarehouseAndDate(String sellerId,String country,String sku,String warehouse,String date);


    /**
     * 根据参数更新FInventoryDaily对象
     * @param quantity
     * @param amount
     * @param id
     * @return
     */
    int updateQuantityAndAmountById(@Param("quantity") Integer quantity,@Param("amount") Double amount,@Param("id") Long id);

    /**
     * 根据参数获取amount的和
     * @param stockSku
     * @param shipmentId
     * @param warehouse
     * @param date
     * @return
     */
    Double selectSumAmountByStockSkuAndShipmentIdAndWarehouseAndDate(String stockSku,String shipmentId,String warehouse,String date);

    /**
     * 根据参数获取amount的和 不包含日期
     * @param stockSku
     * @param shipmentId
     * @param warehouse
     * @return
     */
    Double selectSumAmountByStockSkuAndShipmentIdAndWarehouse(String stockSku,String shipmentId,String warehouse);

    /**
     * 根据参数获取quantity的和
     * @param stockSku
     * @param shipmentId
     * @param warehouse
     * @param date
     * @return
     */
    Integer selectSumQuantityByStockSkuAndShipmentIdAndWarehouseAndDate(String stockSku,String shipmentId,String warehouse,String date);

    /**
     * 根据参数获取quantity的和 不包含日期
     * @param stockSku
     * @param shipmentId
     * @param warehouse
     * @return
     */
    Integer selectSumQuantityByStockSkuAndShipmentIdAndWarehouse(String stockSku,String shipmentId,String warehouse);

    /**
     * 根据参数获取一个map集合（包含amount的和及quantity的和）
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouse
     * @return
     */
    Map selectSumAmountAndSumQuantityBySellerIdAndCountryAndSkuAndWarehouse(String sellerId, String country, String sku, String warehouse);


    /**
     * 根据参数获取一个map集合（包含amount的和及quantity的和）
     * @param sellerId
     * @param country
     * @param fnSku
     * @param warehouse
     * @param date
     * @return
     */
    Map selectSumAmountAndSumQuantityBySellerIdAndCountryAndFnSkuAndWarehouseAndDate(String sellerId, String country, String fnSku, String warehouse,String date);

    /**
     * 根据参数获取amount的和
     * @param sellerId
     * @param country
     * @param sku
     * @param creditSubjectId
     * @param date
     * @return
     */
    Double selectSumAmountBySellerIdAndCountryAndSkuAndCreditSubjectIdAndDate(String sellerId,String country,String sku,String creditSubjectId,String date);

    /**
     * 根据参数获取quantity的和
     * @param sellerId
     * @param country
     * @param sku
     * @param creditSubjectId
     * @param date
     * @return
     */
    Integer selectSumQuantityBySellerIdAndCountryAndSkuAndCreditSubjectIdAndDate(String sellerId,String country,String sku,String creditSubjectId,String date);


    /**
     * 根据参数获取一个map集合（包含amount的和及quantity的和）日期最近的
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouseList
     * @return
     */
    Map selectSumAmountAndSumQuantityBySellerIdAndCountryAndSkuAndWarehouseList(@Param("sellerId") String sellerId, @Param("country") String country, @Param("sku") String sku, @Param("warehouseList") List<String> warehouseList);

    /**
     * 根据参数获取一个map集合（amount的和及quantity的和） 无日期要求
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouseList
     * @return
     */
    Map selectSumAmountAndSumQuantityBySellerIdAndCountryAndSkuAndWarehouseListNoDate(@Param("sellerId") String sellerId, @Param("country") String country, @Param("sku") String sku, @Param("warehouseList") List<String> warehouseList);

    /**
     * 根据参数获取一个map集合（包含amount的和及quantity的和）日期最远的
     * @param sellerId
     * @param country
     * @param sku
     * @param warehouseList
     * @return
     */
    Map selectSumAmountAndSumQuantityBySellerIdAndCountryAndSkuAndWarehouseListAndMinDate(@Param("sellerId") String sellerId, @Param("country") String country, @Param("sku") String sku, @Param("warehouseList") List<String> warehouseList);


    /**
     * 根据参数获取quantity的和
     * @param sellerId
     * @param relatedId
     * @param sku
     * @param warehouse
     * @param approvalDate
     * @return
     */
    Integer selectSumQuantityBySellerIdAndRelatedIdAndSkuAndWarehouse(String sellerId,String relatedId,String sku,String warehouse,String approvalDate);

    /**
     * 根据时间和warehouse获取对应的数据以及根据sellerId country sku 去重
     * @param time
     * @param warehouseList
     * @param isEndAdjustment
     * @param limitValue
     * @return
     */
    List<FInventoryDaily> selectByCreateTimeAndWarehouseAndIsEndAdjustment(@Param("time") String time,@Param("warehouseList") List<String> warehouseList,@Param("isEndAdjustment")Integer isEndAdjustment,@Param("limitValue")Integer limitValue);

    /**
     * 根据参数获取quantity的和
     * @param sellerId
     * @param country
     * @param sku
     * @param fnSku
     * @param warehouseList
     * @param date
     * @return
     */
    Integer selectSumQuantityBySellerIdAndSkuAndFnSkuAndCountryAndDateAndWarehouseList(@Param("sellerId") String sellerId, @Param("country") String country, @Param("sku") String sku, @Param("fnSku") String fnSku , @Param("warehouseList") List<String> warehouseList,@Param("date")String date);

    /**
     * 根据fInventoryDailyList集合对象更新isEndAdjustment
     * @param fInventoryDailyList
     * @return
     */
    int updateIsEndAdjustmentByFInventoryDailyList(@Param("fInventoryDailyList") List<FInventoryDaily> fInventoryDailyList);

    /**
     * 根据fInventoryDailyList集合对象更新amount和Quantity和date
     * @param fInventoryDailyList
     * @return
     */
    int updateAmountAndQuantityAndDateByFInventoryDailyList(@Param("fInventoryDailyList") List<FInventoryDaily> fInventoryDailyList);


    /**
     * 根据日期获取对应的数据
     * @param date
     * @return
     */
    List<FInventoryDaily> selectByDate(String date);

    /**
     * 获取库存记录中最大的日期
     * @return
     */
    String selectMaxDate();

}